﻿using System;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;

namespace ParkManagement
{
    /// <summary>
    /// 里程管理类
    /// </summary>
    public class ConsumptionManager : DomainService
    {
        private readonly IRepository<Consumption, int> _consumptionRepository;

        public ConsumptionManager(
            IRepository<Consumption, int> consumptionRepository)
        {
            _consumptionRepository = consumptionRepository;
        }

        public async Task<Consumption> CreateAsync(
            int userId,
            int carId,
            DateTime travelDate,
            int travelDistance,
            decimal amount,
            double gasFilling)
        {
            return await _consumptionRepository.InsertAsync(
                new Consumption(
                    userId,
                    carId,
                    travelDate,
                    travelDistance,
                    amount,
                    gasFilling
                )
            );
        }
    }
}